import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/system',
    component: Layout,
    redirect: '/system/user',
    name: 'System',
    meta: { title: '系统设置', icon: 'system' },
    children: [
      {
        path: 'user',
        name: 'SystemUser',
        component: () => import('@/views/system/user/index'),
        meta: { title: '管理用户', icon: 'user', authority: 'MANAGEMENT_PERMISSION' }
      },

      {
        path: 'role',
        name: 'SystemRole',
        component: () => import('@/views/system/role/index'),
        meta: { title: '角色管理', icon: 'sss', authority: 'ROLE_PERMISSION' }
      },
      {
        path: 'loginLog',
        name: 'SystemLoginLog',
        component: () => import('@/views/system/log/index'),
        meta: { title: '登陆日志', icon: 'log', authority: 'LOGINLOG_PERMISSION' }
      },
      {
        path: 'help',
        name: 'SystemHelp',
        component: () => import('@/views/system/help/index'),
        meta: { title: '帮助中心', icon: 'help', authority: 'LOGINLOG_PERMISSION' }
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    name: 'Product',
    meta: { title: '商品管理', icon: 'product' },
    children: [
      {
        path: 'category',
        name: 'ProductCategory',
        component: () => import('@/views/product/category/index'),
        meta: { title: '类目管理', icon: 'category' }
      },
      {
        path: 'add',
        name: 'ProductAdd',
        component: () => import('@/views/product/product/add'),
        meta: { title: '添加商品', icon: 'list' },
        hidden: true
      },
      {
        path: 'list',
        name: 'ProductList',
        component: () => import('@/views/product/product/list'),
        meta: { title: '商品列表', icon: 'list' }
      },
      {
        path: 'label',
        name: 'ProductLabel',
        component: () => import('@/views/product/label/index'),
        meta: { title: '商品标签', icon: 'lable' }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    name: 'Order',
    meta: { title: '订单管理', icon: 'order' },
    children: [
      {
        path: 'list',
        name: 'OrderList',
        component: () => import('@/views/order/list'),
        meta: { title: '订单列表', icon: 'list' }
      },
      {
        path: 'afterSale',
        name: 'afterSale',
        component: () => import('@/views/order/afterSale'),
        meta: { title: '售后列表', icon: 'refund' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    name: 'User',
    meta: { title: '用户管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'UserList',
        component: () => import('@/views/user/list'),
        meta: { title: '用户列表', icon: 'user' }
      }
    ]
  },
  {
    path: '/activity',
    component: Layout,
    name: 'Activity',
    meta: { title: '营销管理', icon: 'ffs' },
    children: [
      {
        path: 'market/coupon',
        name: 'marketCoupon',
        component: () => import('@/views/market/coupon'),
        meta: { title: '优惠券管理', icon: 'coupon' }
      }
    ]
  },
  {
    path: '/wrapper',
    component: Layout,
    name: 'Wrapper',
    meta: { title: '商城装修', icon: 'shop' },
    children: [
      {
        path: 'banner',
        name: 'Banner',
        component: () => import('@/views/warpper/banner/index'),
        meta: { title: '轮播图', icon: 'banner' }
      },
      {
        path: 'navigate',
        name: 'Navigate',
        component: () => import('@/views/warpper/navigate/index'),
        meta: { title: '首页导航', icon: 'navigate' }
      },
      {
        path: 'adMan',
        name: 'AdMan',
        component: () => import('@/views/warpper/ad/index'),
        meta: { title: '广告管理', icon: 'ad' }
      },
      {
        path: 'notice',
        name: 'Notice',
        component: () => import('@/views/warpper/notice/index'),
        meta: { title: '通知', icon: 'notice' }
      },
      {
        path: 'word',
        name: 'Word',
        component: () => import('@/views/warpper/hotword/index'),
        meta: { title: '热搜词', icon: 'word' }
      }
    ]
  },
  {
    path: '/find',
    component: Layout,
    name: 'Find',
    meta: { title: '发现管理', icon: 'find' },
    children: [
      {
        path: 'list',
        name: 'FindList',
        component: () => import('@/views/find/index'),
        meta: { title: '发现列表', icon: 'find' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  //mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
